import { actions } from "../../http/actions";
import { hc } from "../../hc";
import HCMqttBaseService from "../BaseService";

export default class HCMQTTAudioService extends HCMqttBaseService {

	/** 获取语音列表 */
	async getAudioList(topic: string) {
		const client = this.getMQTTClient();
		const operator = actions.GetAudio;
		const res = await client.fetch<hc.mqtt.getAudioAck>(topic, {
			operator,
			info: {},
		});
		return res;
	}

	/** 播放语音文件 */
	async playOneAudio(topic: string, name: string) {
		const operator = actions.voiceplay;
		const data = {
			operator,
			info: {
				/** 1播放内置声音文件，2播放客户自定义文件 */
				UsrType: "1",
				voicetype: name,
			},
		};
		const client = this.getMQTTClient();
		const res = await client.fetch<hc.mqtt.voiceplayAck>(topic, data);
		return res;
	}
}
